home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_psutils.idb / usr / freeware / bin / fixpspps.z / fixpspps
Encoding:
Text File  |  1999-07-16  |  1.3 KB  |  62 lines

  1. #!/usr/freeware/bin/perl
  2. eval 'exec perl -S $0 "$@"'
  3.     if $running_under_some_shell;
  4.  
  5. # mangle PostScript produced by PSPrint to make it almost conforming
  6. #
  7. # Copyright (C) Angus J. C. Duggan 1991-1995
  8. # See file LICENSE for details.
  9.  
  10. $header = 1; $ignore = 0;
  11. $verbose = 0;
  12. @body = ();
  13. %fonts = (); $font = "";
  14. $inchar = 0; @char = ();
  15.  
  16. while (<>) {
  17.    if (/^\@end$/) {
  18.       $ignore = 1;
  19.    } elsif (/^[0-9]+ \@bop0$/) {
  20.       $ignore = 0;
  21.       $header = 1;
  22.    } elsif ($header) {
  23.       if (/^\/([a-z.0-9]+) \@newfont$/) {
  24.      if (! defined($fonts{$1})) {
  25.         $fonts{$1} = 1;
  26.         print;
  27.      } elsif ($verbose) {
  28.         print STDERR "$font already defined\n";
  29.      }
  30.       } elsif (/^([a-z.0-9]+) sf$/) {
  31.      $font = $1;
  32.      print;
  33.       } elsif (/^\[</) {
  34.      $inchar = 1;
  35.      push (@char, $_);
  36.       } elsif ($inchar) {
  37.      push (@char, $_);
  38.      if (/.*\] ([0-9]+) dc$/) {
  39.         if (! defined($fonts{$font,$1})) {
  40.            $fonts{$font,$1} = 1;
  41.            print (@char);
  42.         } elsif ($verbose) {
  43.            print STDERR "$font character $1 already defined\n";
  44.         }
  45.         $inchar = 0;
  46.         @char = ();
  47.      }
  48.       } elsif (/^([0-9]+) \@bop1$/) {
  49.      $header = 0;
  50.      push (@body, "%%Page: ? $1\n");
  51.      push (@body, $_);
  52.       } else {
  53.      print;
  54.       }
  55.    } elsif (! $ignore) {
  56.       push (@body, $_);
  57.    }
  58. }
  59. print (@body);
  60. print ("\@end\n");
  61.  
  62.